﻿using System; 
using System.Collections.Generic;
using System.Text;
using XXX.Models;
using fuzhu;
using System.Data; 
using XXX.Models.XXXEntities;
using LH.U8API.Bus;
using ADODB;
using XXX.Common;
using System.Data.SqlClient;
using GLY_XieTong;
using Newtonsoft.Json;

namespace XXX.Bo
{
   public static class DBService
    {
        
       
        public static  string cServer = Common.AppSettings.GetAppSeting("ServerIP");
        public static  string cUserid = Common.AppSettings.GetAppSeting("UserName");
        public static  string cPassword = Common.AppSettings.GetAppSeting("UserPass");
        public static  string cZT = Common.AppSettings.GetAppSeting("U8Account"); 
        public static string cYear;
        public static string cDate;
        public static string cSubId;
        public static string cSerial = "";

        /// <summary>
        /// 获得当前账套对应得组织
        /// </summary>
        /// <returns></returns>
        public static RetModel AA_GetOrgList()
        {
            try
            {
                RetModel retModel = new RetModel();

                List<Orglist> objdata = Common.AppSettings.GetAppSetinglist("orglist");
              
                if (objdata.Count>0)
                {
                    List<object> u8wms002s = objdata.ConvertAll(s => (object)s);
                    return ReOK(u8wms002s);
                }
                else
                {
                    return ReError("查询不到组织列表");
                }

            }
            catch (Exception ex)
            {
                return ReError(ex.Message);
            }

        }



        public static string  GetUserLogin(string dbid)
        {
            //20220413 更改，只获取日期，减少数据库读取

            //try
            //{
            //    string sql = "SELECT ServerIP,UserName,UserPass,U8Account FROM dbo.zdy_inter_database WHERE DBID='1' ";
            //    DataTable dt = DbHelper2.ExecuteTable(sql, conStr);
            //    if (dt.Rows.Count > 0)
            //    {
            //        cServer = DbHelper.GetDbString(dt.Rows[0]["ServerIP"]);
            //        cUserid = DbHelper.GetDbString(dt.Rows[0]["UserName"]);
            //        cPassword = DbHelper.GetDbString(dt.Rows[0]["UserPass"]);
            //        cZT = DbHelper.GetDbString(dt.Rows[0]["U8Account"]);
                    cYear = DateTime.Now.Year.ToString();
                    cDate = DateTime.Now.ToString("yyyy-MM-dd");
                //}
                //else
                //{
                //    return "数据源未配置";
                //}



            //}
            //catch (Exception ex)
            //{
            //    return  ex.Message ;
            //}
            return "ok";
        }

       /// <summary>
       /// U8登陆验证
       /// </summary>
       /// <param name="userid">账号</param>
       /// <param name="password">密码</param>
       /// <returns></returns>
        public static RetModelbool AA_GetUserLoginU8(string corg,string userid, string password)
        {
            //使用sql的验证方式
            try
            {
                string conStr = Common.AppSettings.GetAppSeting(corg);
                if (string.IsNullOrEmpty(conStr))
                {
                    throw new Exception("未配置账套数据库");
                }
                cYear = DateTime.Now.Year.ToString();
                cDate = DateTime.Now.ToString("yyyy-MM-dd");
               
                String sql = string.Format(@" SELECT cUser_Name,cPassword,UFSYSTEM.dbo.FnBase64Encode( HASHBYTES('SHA1','{1}'))+CHAR(3) as pwdlogin   
                    FROM UFSYSTEM..UA_User  WHERE cUser_Id='{0}' ", userid, password);
                DataTable dt = DbHelper2.ExecuteTable(sql, conStr);
                if (dt.Rows.Count > 0)
                {
                    string cUserName = DbHelper.GetDbString(dt.Rows[0]["cUser_Name"]);
                    string cPwd = DbHelper.GetDbString(dt.Rows[0]["cPassword"]);
                    string cPwdlogin = DbHelper.GetDbString(dt.Rows[0]["pwdlogin"]);
                    if (cPwd == cPwdlogin)
                    {
                        return ReOKbool(cUserName);
                    }
                    else
                    {
                        throw new Exception("密码不正确");
                    }
                }
                else
                {
                    throw new Exception("账号不存在");
                }
               
            }
            catch (Exception ex)
            { 
               return ReErrorbool(ex.Message);
            }
             
        }



        /// <summary>
        /// 获得操作员有权限的仓库
        /// </summary>
        /// <param name="cuserid">操作员</param>
        /// <returns></returns>
        public static RetModel AA_GetWarehouseByUser(string corg, string cuserid)
        {
            try
            {

                RetModel retModel = new RetModel();
                string conStr = Common.AppSettings.GetAppSeting(corg);
                if (string.IsNullOrEmpty(conStr))
                {
                    throw new Exception("未配置账套数据库");
                }

                string sqlwh = string.Format(@"SELECT cWhCode,cWhName,convert(varchar(20), bWhpos) as bWhpos FROM dbo.Warehouse where cwhmemo like '%PDA%' ");
                //是不是权限主管或者账套主管
                string sql = "SELECT bAuthControl FROM AA_BusObject_base WHERE cBusObId='warehouse' AND langid='zh-CN' ";

                int iWhControl = DbHelper.GetDbInt(DbHelper2.ExecuteScalar(sql, conStr));
                if (iWhControl == 1)
                {
                    //人员是否是账套主管

                    sql = string.Format(@"SELECT COUNT(*) sl FROM UFSystem..ua_role  WHERE cgroup_id = 'DATA-MANAGER' 
AND cUser_Id = '{0}'", cuserid);
                    int icnt = DbHelper.GetDbInt(DbHelper2.ExecuteScalar(sql, conStr));
                    if (icnt == 0)
                    {
                        //有仓库主管权限
                        sql = string.Format(@"SELECT COUNT(*) sl FROM AA_holdbusobject a
LEFT JOIN UFSystem..UA_Role b ON  a.cUserId = b.cGroup_Id
WHERE iAdmin = 1 AND CBusObId = 'warehouse'
AND((isUserGroup = 0 AND cUserId = '{0}')    OR(isUserGroup = 1 AND b.cUser_Id = '{0}'))", cuserid);
                        icnt = DbHelper.GetDbInt(DbHelper2.ExecuteScalar(sql, conStr));
                        if (icnt == 0)
                        {
                            sqlwh = string.Format(@"SELECT DISTINCT cWhCode,cWhName, convert(varchar(20), bWhpos) as bWhpos FROM AA_HoldAuth a
INNER JOIN warehouse w ON a.caccode= w.cwhcode
LEFT JOIN UFSystem..UA_Role b ON  a.cUserId=b.cGroup_Id  
WHERE cFuncId LIKE '%W%' AND CBusObId='warehouse' AND cwhmemo like '%PDA%'
AND( (isUserGroup =0 AND cUserId = '{0}')    OR (isUserGroup =1 AND b.cUser_Id = '{0}' ))", cuserid);

                        }
                    }

                }
                DataTable dt = DbHelper2.ExecuteTable(sqlwh, conStr);

                if (dt.Rows.Count > 0)
                {
                    List<Warehouse> u8wms001s1 = TableListConverter<Warehouse>.TableToList2(dt);
                    List<object> u8wms002s = u8wms001s1.ConvertAll(s => (object)s);
                    return ReOK(u8wms002s);
                }
                else
                {
                    return ReError("查询不到仓库");
                }

            }
            catch (Exception ex)
            {
                return ReError(ex.Message);
            }

        }
        /// <summary>
        /// 根据仓库编码获取名称
        /// </summary>
        /// <param name="cOrg">组织</param>
        /// <param name="cWhCode">仓库编码</param>
        /// <returns></returns>
        public static RetModel AA_GetWareNameByCode(string cOrg, string cWhCode)
        {
            try
            {

                RetModel retModel = new RetModel();
                string conStr = Common.AppSettings.GetAppSeting(cOrg);
                if (string.IsNullOrEmpty(conStr))
                {
                    throw new Exception("未配置账套数据库");
                }

                string sqlwh = string.Format(@"SELECT cWhCode,cWhName, convert(varchar(20), bWhpos) as bWhpos FROM dbo.Warehouse where cwhmemo like '%PDA%' and cwhcode='{0}' ", cWhCode);
                
                DataTable dt = DbHelper2.ExecuteTable(sqlwh, conStr);

                if (dt.Rows.Count > 0)
                {
                    List<Warehouse> u8wms001s1 = TableListConverter<Warehouse>.TableToList2(dt);
                    List<object> u8wms002s = u8wms001s1.ConvertAll(s => (object)s);
                    return ReOK(u8wms002s);
                }
                else
                {
                    return ReError("查询不到仓库");
                }

            }
            catch (Exception ex)
            {
                return ReError(ex.Message);
            }

        }

        /// <summary>
        /// 读取货位的信息
        /// </summary>
        /// <param name="cOrg">组织</param>
        /// <param name="cWhCode">仓库编码</param>
        /// <param name="cPosCode">货位编码</param>
        /// <returns></returns>
        public static RetModel AA_GetPosCodeByCode(string cOrg, string cWhCode,string cPosCode)
        {
            try
            {

                RetModel retModel = new RetModel();
                string conStr = Common.AppSettings.GetAppSeting(cOrg);
                if (string.IsNullOrEmpty(conStr))
                {
                    throw new Exception("未配置账套数据库");
                }

                string sqlwh = string.Format(@"SELECT cWhCode, cPosCode,cPosName,convert(varchar(20), bPosEnd) as bPosEnd  FROM dbo.Position  WHERE cWhCode='{0}' AND cPosCode='{1}' ", cWhCode,cPosCode);

                DataTable dt = DbHelper2.ExecuteTable(sqlwh, conStr);

                if (dt.Rows.Count > 0)
                {
                    List<Position> u8wms001s1 = TableListConverter<Position>.TableToList2(dt);
                    List<object> u8wms002s = u8wms001s1.ConvertAll(s => (object)s);
                    return ReOK(u8wms002s);
                }
                else
                {
                    return ReError("查询不到货位");
                }

            }
            catch (Exception ex)
            {
                return ReError(ex.Message);
            }

        }
        /// <summary>
        /// 读取条码中的存货编码
        /// </summary>
        /// <param name="corg">组织</param>
        /// <param name="cbarcode">条码</param>
        /// <returns></returns>
        public static RetModel AA_GetBarcode(string corg, string cbarcode)
        {
            try
            {
                if (string.IsNullOrEmpty(cbarcode))
                {
                    throw new Exception("没有扫码！");
                }
                string conStr = Common.AppSettings.GetAppSeting(corg);
                if (string.IsNullOrEmpty(conStr))
                {
                    throw new Exception("未配置账套数据库");
                }
                RetModelbool retModel = new RetModelbool();
                SqlParameter[] param = new SqlParameter[]{
                new SqlParameter("@cbarcode",cbarcode),
                new SqlParameter("@result",SqlDbType.NVarChar,200)

          };
                param[1].Direction = ParameterDirection.Output;

                DataTable dt = DbHelper2.Execute("sp_OMC_GetBarcode", param, CommandType.StoredProcedure, conStr).Tables[0];
                //检查条码是否存在
                string cRe = DbHelper.GetDbString(param[1].Value);
                if (cRe == "ok")
                { ;
                    List<Inventory> u8wms001s1 = TableListConverter<Inventory>.TableToList2(dt);
                    List<object> u8wms002s = u8wms001s1.ConvertAll(s => (object)s);
                    return DBService.ReOK(u8wms002s);
                }
                else
                {
                    return DBService.ReError(cRe);
                }

            }
            catch (Exception ex)
            {
                return DBService.ReError(ex.Message);
            }

        }

        /// <summary>
        /// 查询未入库的到货单,已审核未关闭，不检验的
        /// </summary>
        /// <param name="iid"></param>
        /// <returns></returns>
        public static RetModel PU_GetPuArrival(string corg, string cwhcode, string  ccode )
        {
            try
            {
                string conStr = Common.AppSettings.GetAppSeting(corg);
                if (string.IsNullOrEmpty(conStr))
                {
                    throw new Exception("未配置账套数据库");
                }
                RetModel retModel = new RetModel();
                string sql = string.Format(@"SELECT a.cCode,a.cVenCode,a.cDepCode,a.cPersonCode,a.cPtCode,a.dDate,c.cVenName,b.cInvCode,d.cInvName,com.cComUnitName, b.iQuantity-(ISNULL(b.fValidInQuan,0)+ISNULL(b.fRefuseQuantity,0)) wrksl,b.autoid,
b.cWhCode,a.id,b.iQuantity,(ISNULL(b.fValidInQuan,0)) as fValidInQuan,b.ivouchrowno,0.00 as scanqty,
CASE WHEN   d.cDefWareHouse = B.cWhCode then D.cPosition ELSE '' END AS cPosition  

FROM dbo.PU_ArrivalVouch a
INNER JOIN dbo.PU_ArrivalVouchs b ON  a.id = b.ID
INNER JOIN vendor c ON a.cVenCode=c.cvencode
INNER JOIN inventory d ON b.cinvcode=d.cinvcode
INNER JOIN dbo.ComputationUnit com ON d.cComUnitCode=com.cComunitCode
WHERE ISNULL(b.cbcloser,'')='' and b.bgsp=0   AND ISNULL(a.cverifier,'')<>''
and (b.cwhcode='{1}' or isnull(b.cwhcode,'')='')
AND b.iQuantity>(ISNULL(b.fValidInQuan,0)+ISNULL(b.fRefuseQuantity,0)) and d.bService=0 AND d.cInvCCode <>'J'
AND b.iQuantity>0  and a.ddate>='{0}'  ", CanShu.dBegin, cwhcode
);
                if (ccode != "0")
                {
                    sql += string.Format(" and a.cCode = '{0}'", ccode);
                }
                //排序
                sql += " order by a.cCode, b.cInvCode";
                DataTable dt = DbHelper2.ExecuteTable(sql, conStr);

                if (dt.Rows.Count > 0)
                {
                    List<PuArrivalWrk> u8wms001s1 = TableListConverter<PuArrivalWrk>.TableToList2(dt);
                    List<object> u8wms002s = u8wms001s1.ConvertAll(s => (object)s);
                    return ReOK(u8wms002s);
                }
                else
                {
                    return ReError("没有未入库的到货单");
                }

            }
            catch (Exception ex)
            {
                return ReError(ex.Message);
            }

        }

        /// <summary>
        /// 查询未入库的检验单
        /// </summary>
        /// <param name="iid"></param>
        /// <returns></returns>
        public static RetModel GetPuArrivalQC(string ccheckcode)
        {
            try
            {
                RetModel retModel = new RetModel();
                string sql = string.Format(@"SELECT  ccheckcode,  ar.ccode,ar.cdefine1 AS songhuocode,b.ddate, 
b.cVenCode,v.cVenName,
c.cInvName ,b.cInvCode , b.FREGNUM+ISNULL(b.FCONNUM,0) AS inumsum,
b.FREGQUANTITY+ISNULL(b.FCONQUANTIY,0) AS iQuantitySum,c.cInvStd ,
b.FREGQUANTITY+ISNULL(b.FCONQUANTIY,0)  -ISNULL(b.FsumQuantity,0)   as wrksl,
0.00 as scanqty,
b.FREGNUM+ISNULL(b.FCONNUM,0)-ISNULL(b.FsumNum,0)   as inum,
zjl.cComUnitName  ,d.cComUnitName auxiliaryUOM,
 b.id  AS icheckid ,b.CBATCH 
FROM   
dbo.QMCHECKVOUCHER b
INNER JOIN dbo.PU_ArrivalVouch ar ON b.SOURCECODE=ar.cCode
INNER JOIN dbo.Inventory c ON  b.cInvCode=c.cInvCode
inner join vendor v on b.cvencode= v.cvencode
LEFT JOIN dbo.ComputationUnit zjl ON c.cGroupCode=zjl.cGroupCode AND c.cComunitCode=zjl.cComunitCode
LEFT JOIN dbo.ComputationUnit d ON c.cGroupCode=d.cGroupCode AND b.cUnitID=d.cComunitCode
WHERE b.CVOUCHTYPE='QM03'  AND  (FREGQUANTITY+ISNULL(FCONQUANTIY,0))>ISNULL(FsumQuantity,0) 
and b.ddate>='{0}'  ", CanShu.dBegin
);
                if (ccheckcode != "0" && !string.IsNullOrEmpty(ccheckcode))
                {
                    sql += string.Format(" and b.CCHECKCODE = '{0}'", ccheckcode);
                }
                DataTable dt = DbHelper2.ExecuteTable(sql, CanShu.conStr);

                if (dt.Rows.Count > 0)
                {
                    List<PuArrivalQC> u8wms001s1 = TableListConverter<PuArrivalQC>.TableToList2(dt);
                    List<object> u8wms002s = u8wms001s1.ConvertAll(s => (object)s);
                    return ReOK(u8wms002s);
                }
                else
                {
                    return ReError("没有未入库的来料检验单");
                }

            }
            catch (Exception ex)
            {
                return ReError(ex.Message);
            }

        }


        /// <summary>
        /// 查询拒收单
        /// </summary>
        /// <param name="iid"></param>
        /// <returns></returns>
        public static RetModel GetPuArrivalRefuse(string ccode)
        {
            try
            {
                RetModel retModel = new RetModel();
                string sql = string.Format(@"SELECT a.cdefine1 as cSongHuoCode,a.ccode,a.cVenCode,v.cVenName  ,b.cinvcode,i.cInvName,  b.fRefuseQuantity,b.fSumRefuseQuantity,
com.cComUnitName,
(b.fRefuseQuantity - ISNULL(b.fSumRefuseQuantity,0)) AS jushousl,0.00 as scanqty
,b.Autoid,b.ID
FROM PU_ArrivalVouch a
INNER JOIN dbo.PU_ArrivalVouchs  b on a.id= b.ID
INNER JOIN vendor v ON a.cVenCode=v.cVenCode
INNER JOIN inventory i ON b.cInvCode=i.cInvCode
INNER JOIN dbo.ComputationUnit com ON i.cComUnitCode=com.cComunitCode
where b.fRefuseQuantity>ISNULL(b.fSumRefuseQuantity ,0) and a.ddate>='{0}' ", CanShu.dBegin
);
                if (ccode != "0")
                {
                    sql += string.Format(" and a.cCode = '{0}'", ccode);
                }
                DataTable dt = DbHelper2.ExecuteTable(sql, CanShu.conStr);

                if (dt.Rows.Count > 0)
                {
                    List<PuArrivalRefuse> u8wms001s1 = TableListConverter<PuArrivalRefuse>.TableToList2(dt);
                    List<object> u8wms002s = u8wms001s1.ConvertAll(s => (object)s);
                    return ReOK(u8wms002s);
                }
                else
                {
                    return ReError("没有需要拒收的到货单");
                }

            }
            catch (Exception ex)
            {
                return ReError(ex.Message);
            }

        }


     

        /// <summary>
        /// 查询未出库的采购退货单,已审核未关闭
        /// </summary>
        /// <param name="iid"></param>
        /// <returns></returns>
        public static RetModel PU_GetPuArrival2(string corg, string cwhcode,string ccode)
        {
            try
            {
                string conStr = Common.AppSettings.GetAppSeting(corg);
                if (string.IsNullOrEmpty(conStr))
                {
                    throw new Exception("未配置账套数据库");
                }
                RetModel retModel = new RetModel();
                string sql = string.Format(@"SELECT a.cCode,a.cVenCode, a.cDepCode,a.cPersonCode,a.cPtCode,a.dDate,c.cVenName,b.cInvCode,d.cInvName,com.cComUnitName, b.iQuantity*(-1)-ISNULL(b.fValidInQuan*(-1),0) wrksl,b.autoid,
b.cWhCode,a.id,b.iQuantity*(-1) as iQuantity,b.fValidInQuan*(-1) as fValidInQuan,b.ivouchrowno,0.00 as scanqty FROM dbo.PU_ArrivalVouch a
INNER JOIN dbo.PU_ArrivalVouchs b ON  a.id = b.ID
INNER JOIN vendor c ON a.cVenCode=c.cvencode
INNER JOIN inventory d ON b.cinvcode=d.cinvcode
INNER JOIN dbo.ComputationUnit com ON d.cComUnitCode=com.cComunitCode
WHERE ISNULL(b.cbcloser,'')=''    AND ISNULL(a.cverifier,'')<>''
and (b.cwhcode='{1}' or isnull(b.cwhcode,'')='')
AND b.iQuantity<ISNULL(b.fValidInQuan,0)
AND b.iQuantity<0  and a.ddate>='{0}' ", CanShu.dBegin,cwhcode
);
                if (ccode != "0")
                {
                    sql += string.Format(" and a.cCode = '{0}'", ccode);
                }
                DataTable dt = DbHelper2.ExecuteTable(sql, conStr);

                if (dt.Rows.Count > 0)
                {
                    List<PuArrivalWrk> u8wms001s1 = TableListConverter<PuArrivalWrk>.TableToList2(dt);
                    List<object> u8wms002s = u8wms001s1.ConvertAll(s => (object)s);
                    return ReOK(u8wms002s);
                }
                else
                {
                    return ReError("没有未出库的退货单");
                }

            }
            catch (Exception ex)
            {
                return ReError(ex.Message);
            }

        }


        /// <summary>
        /// 查询未审核的调拨单
        /// </summary>
        /// <param name="iid"></param>
        /// <returns></returns>
        public static RetModel ST_GetTransVouch(string corg, string ccode, string cwhcode)
        {
            try
            {
                string conStr = Common.AppSettings.GetAppSeting(corg);
                if (string.IsNullOrEmpty(conStr))
                {
                    throw new Exception("未配置账套数据库");
                }
                RetModel retModel = new RetModel();
                string sql = string.Format(@"SELECT a.cTVCode, a.cPersonCode, a.dTVDate, b.cInvCode,d.cInvName,com.cComUnitName,
 b.iTVQuantity, b.iTVQuantity AS wrksl  ,b.autoid,
a.cOWhCode,a.id,  b.irowno,0.00 as scanqty  ,a.cIWhCode,w.cWhName AS cIWhName, convert(varchar(20),w.bwhpos) as bWhpos2,
CASE WHEN ISNULL(B.coutposcode,'')='' and  d.cDefWareHouse = a.cOWhCode then D.cPosition ELSE B.coutposcode END AS coutposcode,
CASE WHEN ISNULL(B.cinposcode,'')='' and  d.cDefWareHouse = a.cIWhCode then D.cPosition ELSE B.cinposcode END AS cinposcode
FROM dbo.transvouch a
INNER JOIN dbo.transvouchs b ON  a.id = b.ID 
INNER JOIN inventory d ON b.cinvcode=d.cinvcode
INNER JOIN warehouse w ON a.ciwhcode = w.cwhcode
INNER JOIN dbo.ComputationUnit com ON d.cComUnitCode=com.cComunitCode
WHERE  ISNULL(a.cverifyperson,'')='' and
   a.coWhCode='{1}'
  and a.dTVdate>='{0}' ", CanShu.dBegin, cwhcode);
                if (ccode != "0")
                {
                    sql += string.Format(" and a.cTVCode = '{0}'", ccode);
                }
                //排序
                sql += " order by a.cTVCode, b.cInvCode";
                DataTable dt = DbHelper2.ExecuteTable(sql, conStr);

                if (dt.Rows.Count > 0)
                {
                    List<TransVouch> u8wms001s1 = TableListConverter<TransVouch>.TableToList2(dt);
                    List<object> u8wms002s = u8wms001s1.ConvertAll(s => (object)s);
                    return ReOK(u8wms002s);
                }
                else
                {
                    return ReError("没有未审核的调拨单");
                }

            }
            catch (Exception ex)
            {
                return ReError(ex.Message);
            }

        }

        /// <summary>
        /// 查询未审核的材料出库单
        /// </summary>
        /// <param name="iid"></param>
        /// <returns></returns>
        public static RetModel ST_GetMaterialOut(string corg, string ccode, string cwhcode)
        {
            try
            {
                string conStr = Common.AppSettings.GetAppSeting(corg);
                if (string.IsNullOrEmpty(conStr))
                {
                    throw new Exception("未配置账套数据库");
                }
                RetModel retModel = new RetModel();
                string sql = string.Format(@" SELECT a.cCode, a.cDepCode,a.cPersonCode, a.dDate, b.cInvCode,d.cInvName,com.cComUnitName, b.iQuantity  wrksl,b.autoid,
a.cWhCode,a.id,b.iQuantity, b.irowno,0.00 as scanqty, 
CASE WHEN ISNULL(B.cPosition,'')='' and  d.cDefWareHouse = a.cWhCode then D.cPosition ELSE B.cPosition END AS cPosition 
FROM dbo.rdrecord11 a
INNER JOIN dbo.rdrecords11 b ON  a.id = b.ID 
INNER JOIN inventory d ON b.cinvcode=d.cinvcode
INNER JOIN dbo.ComputationUnit com ON d.cComUnitCode=com.cComunitCode
WHERE  ISNULL(a.cHandler,'')=''
 AND b.iQuantity>0 AND a.cWhCode='{1}'
  and a.ddate>='{0}' ", CanShu.dBegin, cwhcode);
                if (ccode != "0")
                {
                    sql += string.Format(" and a.cCode = '{0}'", ccode);
                }
                //排序
                sql += " order by a.cCode, b.cInvCode";
                DataTable dt = DbHelper2.ExecuteTable(sql, conStr);

                if (dt.Rows.Count > 0)
                {
                    List<MaterialOtherOut> u8wms001s1 = TableListConverter<MaterialOtherOut>.TableToList2(dt);
                    List<object> u8wms002s = u8wms001s1.ConvertAll(s => (object)s);
                    return ReOK(u8wms002s);
                }
                else
                {
                    return ReError("没有未审核的材料出货单");
                }

            }
            catch (Exception ex)
            {
                return ReError(ex.Message);
            }

        }


        /// <summary>
        /// 查询未审核的材料出库单
        /// </summary>
        /// <param name="iid"></param>
        /// <returns></returns>
        public static RetModel ST_GetMaterialOut2(string corg, string ccode, string cwhcode)
        {
            try
            {
                string conStr = Common.AppSettings.GetAppSeting(corg);
                if (string.IsNullOrEmpty(conStr))
                {
                    throw new Exception("未配置账套数据库");
                }
                RetModel retModel = new RetModel();
                string sql = string.Format(@"SELECT a.cCode, a.cDepCode,a.cPersonCode, a.dDate, b.cInvCode,d.cInvName,com.cComUnitName, 0-b.iQuantity  wrksl,b.autoid,
a.cWhCode,a.id,0-b.iQuantity as iQuantity, b.irowno,0.00 as scanqty 
FROM dbo.rdrecord11 a
INNER JOIN dbo.rdrecords11 b ON  a.id = b.ID 
INNER JOIN inventory d ON b.cinvcode=d.cinvcode
INNER JOIN dbo.ComputationUnit com ON d.cComUnitCode=com.cComunitCode
WHERE  ISNULL(a.cHandler,'')=''
 AND b.iQuantity<0 AND a.cWhCode='{1}'
  and a.ddate>='{0}'  ", CanShu.dBegin, cwhcode);
                if (ccode != "0")
                {
                    sql += string.Format(" and a.cCode = '{0}'", ccode);
                }
                DataTable dt = DbHelper2.ExecuteTable(sql, conStr);

                if (dt.Rows.Count > 0)
                {
                    List<MaterialOtherOut> u8wms001s1 = TableListConverter<MaterialOtherOut>.TableToList2(dt);
                    List<object> u8wms002s = u8wms001s1.ConvertAll(s => (object)s);
                    return ReOK(u8wms002s);
                }
                else
                {
                    return ReError("没有未审核的材料出货单");
                }

            }
            catch (Exception ex)
            {
                return ReError(ex.Message);
            }

        }


        /// <summary>
        /// 查询未审核的其他出库单
        /// </summary>
        /// <param name="iid"></param>
        /// <returns></returns>
        public static RetModel GetMaterialOtherOut(string ccode,string cwhcode)
        {
            try
            {
                //string sql = string.Format("select * from AA_PARA WHERE ctype='车间调拨出库仓库'");
                //string cWhcode = DbHelper.GetDbString(DbHelper2.ExecuteScalar(sql, CanShu.conStr));


                RetModel retModel = new RetModel();
               string sql = string.Format(@"SELECT a.cCode, a.cDepCode,a.cPersonCode, a.dDate, b.cInvCode,d.cInvName,com.cComUnitName, b.iQuantity  wrksl,b.autoid,
a.cWhCode,a.id,b.iQuantity, b.irowno,0.00 as scanqty 
FROM dbo.rdrecord09 a
INNER JOIN dbo.rdrecords09 b ON  a.id = b.ID 
INNER JOIN inventory d ON b.cinvcode=d.cinvcode
INNER JOIN dbo.ComputationUnit com ON d.cComUnitCode=com.cComunitCode
WHERE  ISNULL(a.cHandler,'')=''
 AND b.iQuantity>0 AND a.cWhCode='{1}'
  and a.ddate>='{0}' ", CanShu.dBegin, cwhcode);
                if (ccode != "0")
                {
                    sql += string.Format(" and a.cCode = '{0}'", ccode);
                }
               //排序
                    sql += " order by a.cCode, b.cInvCode";
                
                DataTable dt = DbHelper2.ExecuteTable(sql, CanShu.conStr);

                if (dt.Rows.Count > 0)
                {
                    List<MaterialOtherOut> u8wms001s1 = TableListConverter<MaterialOtherOut>.TableToList2(dt);
                    List<object> u8wms002s = u8wms001s1.ConvertAll(s => (object)s);
                    return ReOK(u8wms002s);
                }
                else
                {
                    return ReError("没有未审核的其他出货单");
                }

            }
            catch (Exception ex)
            {
                return ReError(ex.Message);
            }

        }



        /// <summary>
        /// 查询未审核的其他出库单，负数的
        /// </summary>
        /// <param name="iid"></param>
        /// <returns></returns>
        public static RetModel GetMaterialOtherOut2(string ccode, string cwhcode)
        {
            try
            {
                //string sql = string.Format("select * from AA_PARA WHERE ctype='车间调拨出库仓库'");
                //string cWhcode = DbHelper.GetDbString(DbHelper2.ExecuteScalar(sql, CanShu.conStr));


                RetModel retModel = new RetModel();
                string sql = string.Format(@"SELECT a.cCode, a.cDepCode,a.cPersonCode, a.dDate, b.cInvCode,d.cInvName,com.cComUnitName, 0-b.iQuantity  wrksl,b.autoid,
a.cWhCode,a.id,0-b.iQuantity as iQuantity, b.irowno,0.00 as scanqty 
FROM dbo.rdrecord09 a
INNER JOIN dbo.rdrecords09 b ON  a.id = b.ID 
INNER JOIN inventory d ON b.cinvcode=d.cinvcode
INNER JOIN dbo.ComputationUnit com ON d.cComUnitCode=com.cComunitCode
WHERE  ISNULL(a.cHandler,'')=''
 AND b.iQuantity<0 AND a.cWhCode='{1}'
  and a.ddate>='{0}' ", CanShu.dBegin, cwhcode);
                if (ccode != "0")
                {
                    sql += string.Format(" and a.cCode = '{0}'", ccode);
                }
                DataTable dt = DbHelper2.ExecuteTable(sql, CanShu.conStr);

                if (dt.Rows.Count > 0)
                {
                    List<MaterialOtherOut> u8wms001s1 = TableListConverter<MaterialOtherOut>.TableToList2(dt);
                    List<object> u8wms002s = u8wms001s1.ConvertAll(s => (object)s);
                    return ReOK(u8wms002s);
                }
                else
                {
                    return ReError("没有未审核的其他出货单");
                }

            }
            catch (Exception ex)
            {
                return ReError(ex.Message);
            }

        }


        /// <summary>
        /// 查询未出库的发货单
        /// </summary>
        /// <param name="iid"></param>
        /// <returns></returns>
        public static RetModel SA_GetDispatchlist(string corg,string ccode,string cwhcode )
        {
            try
            {
                string conStr = Common.AppSettings.GetAppSeting(corg);
                if (string.IsNullOrEmpty(conStr))
                {
                    throw new Exception("未配置账套数据库");
                }
                RetModel retModel = new RetModel();
                string sql = string.Format(@"SELECT a.cDLCode,a.cCusCode,a.cDepCode,a.cPersonCode,a.cStCode,a.dDate,c.cCusName,b.cInvCode,d.cInvName,com.cComUnitName, b.iQuantity-ISNULL(b.fOutQuantity,0) wrksl,b.idlsid as autoid,
b.cWhCode,a.dlid,b.iQuantity,b.fOutQuantity,b.irowno,0.00 as scanqty ,
CASE WHEN ISNULL(B.cPosition,'')='' AND d.cDefWareHouse = B.cWhCode then D.cPosition ELSE B.cPosition END AS cPosition 

FROM dbo.DispatchList a
INNER JOIN dbo.DispatchLists b ON  a.DLID = b.DLID
INNER JOIN customer c ON a.cCusCode=c.cCusCode
INNER JOIN inventory d ON b.cinvcode=d.cinvcode
INNER JOIN dbo.ComputationUnit com ON d.cComUnitCode=com.cComunitCode
WHERE ISNULL(b.cscloser,'')=''    AND ISNULL(a.cverifier,'')<>''
AND b.iQuantity>ISNULL(b.fOutQuantity,0)
AND b.iQuantity>0  and a.ddate>='{0}' AND b.cWhCode='{1}' ", CanShu.dBegin,cwhcode
);
                if (ccode != "0")
                {
                    sql += string.Format(" and a.cDLCode = '{0}'", ccode);
                }
                //排序
                sql += " order by a.cDLCode, b.cInvCode";
                DataTable dt = DbHelper2.ExecuteTable(sql, conStr);

                if (dt.Rows.Count > 0)
                {
                    List<SaDispatchlist> lst = TableListConverter<SaDispatchlist>.TableToList2(dt);
                    //循环，新增先进先出的条码
          //          for (int i = 0; i < lst.Count; i++)
          //          {
          //              string cInvcode = lst[i].cInvCode;
          //              string cWhcode = lst[i].cWhCode;
          //              decimal dqyt = lst[i].wcksl;

          //              SqlParameter[] param = new SqlParameter[]{
          //              new SqlParameter("@cinvcode",cInvcode),
          //               new SqlParameter("@cwhcode",cWhcode),
          //               new SqlParameter("@cksqty",dqyt) 
          //};
                        
          //            DataTable dtfifo = DbHelper2.Execute("SP_FIFO", param, CommandType.StoredProcedure,WMSService.conStr).Tables[0];
          //              List<FIFOBarcodes> fIFOBarcodes = TableListConverter<FIFOBarcodes>.TableToList2(dtfifo);
          //              lst[i].fifolist = fIFOBarcodes;

          //          }


                  
                    List<object> u8wms002s = lst.ConvertAll(s => (object)s);
                    return ReOK(u8wms002s);
                }
                else
                {
                    return ReError("没有未出库的发货单");
                }

            }
            catch (Exception ex)
            {
                return ReError(ex.Message);
            }

        }


        /// <summary>
        /// 查询未入库的销售退货单
        /// </summary>
        /// <param name="iid"></param>
        /// <returns></returns>
        public static RetModel SA_GetDispatchlist2(string corg,string ccode, string cwhcode)
        {
            try
            {
                string conStr = Common.AppSettings.GetAppSeting(corg);
                if (string.IsNullOrEmpty(conStr))
                {
                    throw new Exception("未配置账套数据库");
                }
                RetModel retModel = new RetModel();
                string sql = string.Format(@"SELECT a.cDLCode,a.cCusCode,a.cDepCode,a.cPersonCode,a.cStCode,a.dDate,c.cCusName,b.cInvCode,d.cInvName,com.cComUnitName, (b.iQuantity-ISNULL(b.fOutQuantity,0))*(-1) wcksl,b.idlsid ,
b.cWhCode,a.dlid,b.iQuantity*(-1),b.fOutQuantity*(-1),b.irowno,0.00 as scanqty 
FROM dbo.DispatchList a
INNER JOIN dbo.DispatchLists b ON  a.DLID = b.DLID
INNER JOIN customer c ON a.cCusCode=c.cCusCode
INNER JOIN inventory d ON b.cinvcode=d.cinvcode
INNER JOIN dbo.ComputationUnit com ON d.cComUnitCode=com.cComunitCode
WHERE ISNULL(b.cscloser,'')=''    AND ISNULL(a.cverifier,'')<>''
AND b.iQuantity<ISNULL(b.fOutQuantity,0)
AND b.iQuantity<0  and a.ddate>='{0}' AND b.cWhCode='{1}' ", CanShu.dBegin, cwhcode
);
                if (ccode != "0")
                {
                    sql += string.Format(" and a.cDLCode = '{0}'", ccode);
                }
                DataTable dt = DbHelper2.ExecuteTable(sql,  conStr);

                if (dt.Rows.Count > 0)
                {
                    List<SaDispatchlist> u8wms001s1 = TableListConverter<SaDispatchlist>.TableToList2(dt);
                    List<object> u8wms002s = u8wms001s1.ConvertAll(s => (object)s);
                    return ReOK(u8wms002s);
                }
                else
                {
                    return ReError("没有未入库的退货单");
                }

            }
            catch (Exception ex)
            {
                return ReError(ex.Message);
            }

        }


        /// <summary>
        /// 查询未确认的入库单
        /// </summary>
        /// <param name="iid"></param>
        /// <returns></returns>
        public static RetModel ST_GetProductIn(string corg,string ccode,string cwhcode)
        {
            try
            {
                string conStr = Common.AppSettings.GetAppSeting(corg);
                if (string.IsNullOrEmpty(conStr))
                {
                    throw new Exception("未配置账套数据库");
                }
                string sql = string.Format(@"SELECT a.cCode,b.cMoCode, a.cDepCode,a.cPersonCode, a.dDate, b.cInvCode,d.cInvName,com.cComUnitName, b.iQuantity  wrksl,b.autoid,
a.cWhCode,a.id,b.iQuantity, b.irowno,0.00 as scanqty ,
CASE WHEN ISNULL(B.cPosition,'')='' AND d.cDefWareHouse = A.cWhCode then D.cPosition ELSE B.cPosition END AS cPosition 

FROM dbo.rdrecord10 a
INNER JOIN dbo.rdrecords10 b ON  a.id = b.ID 
INNER JOIN inventory d ON b.cinvcode=d.cinvcode
INNER JOIN dbo.ComputationUnit com ON d.cComUnitCode=com.cComunitCode
WHERE  ISNULL(a.cHandler,'')=''
 AND b.iQuantity>0 AND a.cWhCode='{1}'
  and a.ddate>='{0}' ", CanShu.dBegin, cwhcode);
                if (ccode != "0")
                {
                    sql += string.Format(" and a.cCode = '{0}'", ccode);
                }
                //排序
                sql += " order by a.cCode, b.cInvCode";
                DataTable dt = DbHelper2.ExecuteTable(sql, conStr); 

                if (dt.Rows.Count > 0)
                {
                    List<ProductIn> u8wms001s1 = TableListConverter<ProductIn>.TableToList2(dt);
                    List<object> u8wms002s = u8wms001s1.ConvertAll(s => (object)s);
                    return ReOK(u8wms002s);
                }
                else
                {
                    return ReError("没有未审核的入库单");
                }

            }
            catch (Exception ex)
            {
                return ReError(ex.Message);
            }

        }


        /// <summary>
        /// 查询未确认的红字入库单
        /// </summary>
        /// <param name="iid"></param>
        /// <returns></returns>
        public static RetModel ST_GetProductIn2(string corg, string ccode, string cwhcode)
        {
            try
            {
                string conStr = Common.AppSettings.GetAppSeting(corg);
                if (string.IsNullOrEmpty(conStr))
                {
                    throw new Exception("未配置账套数据库");
                }
                string sql = string.Format(@"SELECT a.cCode,b.cMoCode, a.cDepCode,a.cPersonCode, a.dDate, b.cInvCode,d.cInvName,com.cComUnitName, 0-b.iQuantity  wrksl,b.autoid,
a.cWhCode,a.id,0-b.iQuantity as iQuantity, b.irowno,0.00 as scanqty 
FROM dbo.rdrecord10 a
INNER JOIN dbo.rdrecords10 b ON  a.id = b.ID 
INNER JOIN inventory d ON b.cinvcode=d.cinvcode
INNER JOIN dbo.ComputationUnit com ON d.cComUnitCode=com.cComunitCode
WHERE  ISNULL(a.cHandler,'')=''
 AND b.iQuantity<0 AND a.cWhCode='{1}'
  and a.ddate>='{0}' ", CanShu.dBegin, cwhcode);
                if (ccode != "0")
                {
                    sql += string.Format(" and a.cCode = '{0}'", ccode);
                }
                DataTable dt = DbHelper2.ExecuteTable(sql, conStr);

                if (dt.Rows.Count > 0)
                {
                    List<ProductIn> u8wms001s1 = TableListConverter<ProductIn>.TableToList2(dt);
                    List<object> u8wms002s = u8wms001s1.ConvertAll(s => (object)s);
                    return ReOK(u8wms002s);
                }
                else
                {
                    return ReError("没有未审核的红字入库单");
                }

            }
            catch (Exception ex)
            {
                return ReError(ex.Message);
            }

        }


        /// <summary>
        /// 获得未审核的盘点单
        /// </summary>
        /// <param name="cTable">查询的表明，WMS_TASK,WMS_RDRECORD</param>
        /// <returns></returns>
        public static RetModel ST_GetPanDian(string corg, string ccode)
        {
            try
            {
                string conStr = Common.AppSettings.GetAppSeting(corg);
                if (string.IsNullOrEmpty(conStr))
                {
                    throw new Exception("未配置账套数据库");
                }
                RetModel retModel = new RetModel();
                string sql = string.Format(@"SELECT a.id, cCVCode,dCVDate,A.cWhCode,B.cWhName FROM dbo.CheckVouch A,
dbo.Warehouse B   WHERE  A.cWhCode=B.cWhCode AND  ISNULL(cAccounter,'')=''  AND dCVDate>='{0}' ", CanShu.dBegin
);

                DataTable dt = DbHelper2.ExecuteTable(sql, conStr);

                if (dt.Rows.Count > 0)
                {
                    List<PanDianVouch> u8wms001s1 = TableListConverter<PanDianVouch>.TableToList2(dt);
                    List<object> u8wms002s = u8wms001s1.ConvertAll(s => (object)s);
                    return DBService.ReOK(u8wms002s);
                }
                else
                {
                    return DBService.ReError("没有未审核的盘点单");
                }

            }
            catch (Exception ex)
            {
                return DBService.ReError(ex.Message);
            }
        }
        /// <summary>
        /// 获得未审核的盘点单
        /// </summary>
        /// <param name="cTable">查询的表明，WMS_TASK,WMS_RDRECORD</param>
        /// <returns></returns>
        public static RetModel ST_GetPanDianDetail(string corg,string ccode)
        {
            try
            {
                string conStr = Common.AppSettings.GetAppSeting(corg);
                if (string.IsNullOrEmpty(conStr))
                {
                    throw new Exception("未配置账套数据库");
                }
                RetModel retModel = new RetModel();
                string sql = string.Format(@"SELECT b.id,autoID, cast(a.irowno as varchar(20)) AS irowno, a.cInvCode,i.cInvName,i.cInvStd,a.cCVBatch,a.cposition as cPosCode,
convert(varchar(20),convert(real,iCVQuantity)) as iCVQuantity,convert(varchar(20),convert(real,iCVCQuantity )) as iCVCQuantity,cFree1,cFree2,a.cCVCode,
CONVERT(VARCHAR(20),dMadeDate,23) AS dMadeDate,b.cWhCode,
c.cWhName,cast(0 as decimal(18,6) ) as scanqty
 FROM  CheckVouchs a,dbo.CheckVouch b,warehouse c,inventory i 
  WHERE a.cCVCode=b.cCVCode AND b.cWhCode=c.cWhCode and a.cinvcode=i.cinvcode
and a.cCVCode ='{0}' ", ccode);

                DataTable dt = DbHelper2.ExecuteTable(sql,  conStr);

                if (dt.Rows.Count > 0)
                {
                    List<PanDianVouchs> u8wms001s1 = TableListConverter<PanDianVouchs>.TableToList2(dt);
                    List<object> u8wms002s = u8wms001s1.ConvertAll(s => (object)s);
                    return DBService.ReOK(u8wms002s);
                }
                else
                {
                    return DBService.ReError("没有盘点单明细");
                }

            }
            catch (Exception ex)
            {
                return DBService.ReError(ex.Message);
            }
        }

        /// <summary>
        /// 获得未审核的盘点单
        /// </summary>
        /// <param name="cTable">查询的表明，WMS_TASK,WMS_RDRECORD</param>
        /// <returns></returns>
        public static RetModel GetPanDian_barcodes(string ccode)
        {
            try
            {
                RetModel retModel = new RetModel();
                string sql = string.Format(@"SELECT SOURCECODE  AS cCVCode,a.BARCODENO,a.CTYPE,b.INVCODE,b.TOTALQTY FROM dbo.WMS_RDRECORDS_ORI a
INNER JOIN dbo.WMS_BARCODE b ON a.BARCODENO=b.BARCODENO
where a.ctype='盘点' and SOURCECODE ='{0}' ", ccode);

                DataTable dt = DbHelper2.ExecuteTable(sql, WMSService.conStr);

                if (dt.Rows.Count > 0)
                {
                    List<PanDianVouch_barcodes> u8wms001s1 = TableListConverter<PanDianVouch_barcodes>.TableToList2(dt);
                    List<object> u8wms002s = u8wms001s1.ConvertAll(s => (object)s);
                    return DBService.ReOK(u8wms002s);
                }
                else
                {
                    return DBService.ReError("没有盘点单明细");
                }

            }
            catch (Exception ex)
            {
                return DBService.ReError(ex.Message);
            }
        }

        #region 获得现存量
        public static RetModel Rep_GetInvStock(string corg,string cwhcode, string cinvcode)
        {
            try
            {
                string conStr = Common.AppSettings.GetAppSeting(corg);
                if (string.IsNullOrEmpty(conStr))
                {
                    throw new Exception("未配置账套数据库");
                }
                string condition = "";
                if (!string.IsNullOrEmpty(cwhcode) && cwhcode != "")
                {
                    condition += String.Format(@" and a.cWhCode='{0}'", cwhcode);
                }
                if (!string.IsNullOrEmpty(cinvcode) && cinvcode != "")
                {
                    condition += String.Format(@" and A.cInvCode='{0}'", cinvcode);
                }
                string sql = String.Format(@"SELECT a.cWhCode,b.cWhName,a.cInvCode,i.cInvName,convert(varchar(20),convert(real,SUM(a.iQuantity))) AS iQuantity FROM dbo.CurrentStock a,warehouse b ,dbo.Inventory i
 WHERE a.cWhCode=b.cwhcode AND a.cInvCode=i.cInvCode {0}
 GROUP BY a.cWhCode,b.cWhName,a.cInvCode,i.cInvName", condition);


                DataTable dt = DbHelper2.ExecuteTable(sql, conStr);
                if (dt.Rows.Count > 0)
                {
                    List<ReportInvStock> u8wms001s1 = TableListConverter<ReportInvStock>.TableToList2(dt);
                    List<object> u8wms002s = u8wms001s1.ConvertAll(s => (object)s);
                    return DBService.ReOK(u8wms002s);
                }
                else
                {
                    return DBService.ReError("没有现存量");
                }
            }
            catch(Exception ex)
            {

                return DBService.ReError(ex.Message);
            }
        }
        #endregion

        #region 获得货位现存量
        public static RetModel Rep_GetInvPosStock(string corg, string cwhcode, string cposcode, string cinvcode)
        {
            try
            {
                string conStr = Common.AppSettings.GetAppSeting(corg);
                if (string.IsNullOrEmpty(conStr))
                {
                    throw new Exception("未配置账套数据库");
                }
                string condition = "";
                if (!string.IsNullOrEmpty(cwhcode) && cwhcode != "")
                {
                    condition += String.Format(@" and a.cWhCode='{0}'", cwhcode);
                }
                if (!string.IsNullOrEmpty(cinvcode) && cinvcode != "")
                {
                    condition += String.Format(@" and A.cInvCode='{0}'", cinvcode);
                }
                if (!string.IsNullOrEmpty(cposcode) && cposcode != "")
                {
                    condition += String.Format(@" and A.cPosCode='{0}'", cposcode);
                }
                string sql = String.Format(@" SELECT a.cWhCode,b.cWhName,a.cPosCode,p.cPosName,  a.cInvCode,i.cInvName,convert(varchar(20),convert(real,SUM(a.iQuantity)))  AS iQuantity 
 FROM dbo.InvPositionSum a
 INNER JOIN warehouse b  ON  a.cWhCode=b.cwhcode
 INNER JOIN dbo.Position p ON a.cPosCode = p.cPosCode
 INNER JOIN  dbo.Inventory i on a.cInvCode=i.cInvCode
where 1= 1 {0}
 GROUP BY  a.cWhCode,b.cWhName,a.cPosCode,p.cPosName,a.cInvCode,i.cInvName", condition);


                DataTable dt = DbHelper2.ExecuteTable(sql, conStr);
                if (dt.Rows.Count > 0)
                {
                    List<ReportInvStock> u8wms001s1 = TableListConverter<ReportInvStock>.TableToList2(dt);
                    List<object> u8wms002s = u8wms001s1.ConvertAll(s => (object)s);
                    return DBService.ReOK(u8wms002s);
                }
                else
                {
                    return DBService.ReError("没有现存量");
                }
            }
            catch (Exception ex)
            {

                return DBService.ReError(ex.Message);
            }
        }
        #endregion
        //不是list的，直接是类
        public static RetModel2 ReOK(object reData)
        {
            RetModel2 retModel = new RetModel2();
            retModel.code = 200;
            retModel.message = null;
            retModel.data = reData;
            return retModel;
        }

        public static RetModel ReOK(List<object> reData )
        {
            RetModel retModel = new RetModel();
            retModel.code = 200;
            retModel.message = null;
            retModel.data = reData;
            return retModel;
         }
        public static RetModel ReError(string msg)
        {
            RetModel retModel = new RetModel();
            retModel.code =300;
            retModel.message = msg;
            retModel.data = null;
            return retModel;
        }

        public static RetModelbool ReOKbool()
        {
            RetModelbool retModel = new RetModelbool();
            retModel.code = 200;
            retModel.data = true; 
            return retModel;
        }

        public static RetModelbool ReOKbool(string msg)
        {
            RetModelbool retModel = new RetModelbool();
            retModel.code = 200;
            retModel.message= msg;
            retModel.data = true;
            return retModel;
        }
        public static RetModelbool ReErrorbool(string msg)
        {
            RetModelbool retModel = new RetModelbool();
            retModel.code = 300;
            retModel.message = msg;
            retModel.data = false;
            return retModel;
        }



    }
}
